home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Text / Sources / TextProxy.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  4.2 KB  |  157 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                            TextProxy.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Author:                        Anthone Burbidge
  7. //    Creation Date:        3/28/94
  8. //
  9. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. // ----- Macintosh Includes -----
  14.  
  15. #ifndef __FIXMATH__
  16. #include <FixMath.h>
  17. #endif
  18.  
  19. #ifndef mathRoutinesIncludes
  20. #include <math routines.h>
  21. #endif
  22.  
  23. // ----- OpenDoc Includes -----
  24.  
  25. #ifndef _SHAPE_
  26. #include "Shape.h"
  27. #endif
  28.  
  29. // ----- Framework Includes -----
  30.  
  31. #ifndef FWUTIL_H
  32. #include "FWUtil.h"
  33. #endif
  34.  
  35. // ----- TextPart Includes -----
  36.  
  37. #ifndef _TEXTPROXY_
  38. #include "TextProxy.h"
  39. #endif
  40.  
  41. #ifndef _TRNSFORM_
  42. #include <Trnsform.h>
  43. #endif
  44.  
  45. #ifndef FWRECT_H
  46. #include "FWRect.h"
  47. #endif
  48.  
  49. #pragma segment TextPartSegment
  50.  
  51.  
  52. //=============================================================================
  53. // CLASS CTextProxyRun
  54. //=============================================================================
  55.  
  56. //-----------------------------------------------------------------------------
  57. // CTextProxyRun::CTextProxyRun
  58. //-----------------------------------------------------------------------------
  59.  
  60. CTextProxyRun::CTextProxyRun()
  61. {
  62. }
  63.  
  64. //-----------------------------------------------------------------------------
  65. // CTextProxyRun::InitTextProxyRun
  66. //-----------------------------------------------------------------------------
  67.  
  68. void CTextProxyRun::InitTextProxyRun(FW_CEmbeddingPart* embeddingPart)
  69. {
  70.     this->InitProxyRun(embeddingPart);
  71. }
  72.  
  73. //-----------------------------------------------------------------------------
  74. // CTextProxyRun::~CTextProxyRun
  75. //-----------------------------------------------------------------------------
  76.  
  77. CTextProxyRun::~CTextProxyRun()
  78. {
  79. }
  80.  
  81. //-----------------------------------------------------------------------------
  82. // CTextProxyRun::UsedShapeChanged
  83. //-----------------------------------------------------------------------------
  84.  
  85. void CTextProxyRun::UsedShapeChanged(XMPFrame* xmpFrame)
  86. {
  87.     // We assume here that all embedded facets have the same
  88.     // externalTransform
  89.     
  90.     XMPFrameFacetIterator* ite = xmpFrame->CreateFacetIterator();
  91.     XMPFacet *xmpFacet = ite->First();
  92.     delete ite;
  93.     
  94.     if (xmpFacet)
  95.     {
  96.         FW_CRect rect;
  97.         XMPShape *shape = ::NewXMPShape(xmpFrame->GetFrameShape());
  98.         shape->Transform(xmpFacet->GetExternalTransform());
  99.         shape->GetBoundingBox(&rect);
  100.         rect.AsPlatformRect(fBoundingBox);
  101.         delete shape;
  102.     }
  103.     
  104.     FW_CProxyRun::UsedShapeChanged(xmpFrame);
  105. }
  106.  
  107. //-----------------------------------------------------------------------------
  108. // CTextProxyRun::GetFacetExternalTransform
  109. //-----------------------------------------------------------------------------
  110.  
  111. void CTextProxyRun::GetFacetExternalTransform(XMPFrame* xmpFrame,
  112.                                                XMPTransform* facetTransform)
  113. {
  114. FW_UNUSED(xmpFrame);
  115.  
  116.     facetTransform->Reset();
  117.     FW_CPoint offset(ff(fBoundingBox.left), ff(fBoundingBox.top));
  118.     facetTransform->MoveBy(offset);
  119. }
  120.  
  121. //----------------------------------------------------------------------------------------
  122. // CTextProxyRun::SetSelectState
  123. //----------------------------------------------------------------------------------------
  124.  
  125. void CTextProxyRun::SetSelectState(FW_Boolean state)
  126. {
  127.     FW_CProxyRun::SetSelectState(state);
  128.     
  129.     // ----- Set the selected flag in facet -----
  130.     BC_TCollectionActiveIterator<FW_CProxyFrame*> ite(*this->GetProxyFrameList());
  131.     while (!ite.IsDone())
  132.     {
  133.         XMPFrameFacetIterator ite2((*ite.CurrentItem())->GetXMPFrame());
  134.         for (XMPFacet* xmpFacet = ite2.First(); ite2.IsNotComplete(); xmpFacet = ite2.Next())
  135.             xmpFacet->SetSelected(state);
  136.         ite.Next();
  137.     }
  138. }
  139.  
  140. //----------------------------------------------------------------------------------------
  141. // CTextProxyRun::SetBoundingBox
  142. //----------------------------------------------------------------------------------------
  143.  
  144. void CTextProxyRun::SetBoundingBox(const FW_SPlatformRect& rect)
  145. {
  146.     fBoundingBox = rect;
  147. }
  148.  
  149. //----------------------------------------------------------------------------------------
  150. // CTextProxyRun::GetBoundingBox
  151. //----------------------------------------------------------------------------------------
  152.  
  153. void CTextProxyRun::GetBoundingBox(FW_SPlatformRect& rect) const
  154. {
  155.     rect = fBoundingBox;
  156. }
  157.